﻿@{
    ViewBag.Title = "Manage Modules";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

@model DirigoEdge.Areas.Admin.Models.ViewModels.ManageModulesViewModel

<div class="manageModule">

    <div class="row">
        <div class="twelve columns">
            <h3>Content Modules</h3>
            <a id="NewContentModule" class="button mobileBlockStatic mobileMarginBottom" href="@Url.Action("NewContentModule", "Admin")">New Module +</a>
            <table class="manageTable twelve bordered">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th class="hide-for-small">Created</th>
                        <th class="actions">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @{
					    foreach(var module in Model.Modules)
					    {
                        <tr>
                            <td class="title"><a href="@Url.Action("EditModule", "Admin", new { id = @module.ContentModuleId })">@module.ModuleName</a></td>
                            <td class="hide-for-small">@Convert.ToDateTime(module.CreateDate).ToString("MM/dd/yyyy")</td>
                            <td>
                                <a class="delete button secondary small mobileMarginBottom" href="javascript:void(0);" data-id="@module.ContentModuleId">Delete</a>

                                <a class="hide button small mobileTop" href="@Url.Action("EditModule", "Admin", new { id = @module.ContentModuleId })" >Basic Edit</a>
                                
                                
                                
                                <div href="#" class="secondary small button dropdown">
                                  <i class="fa fa-gear"></i>
                                  <ul>
                                    <li><a href="@Url.Action("CloneModule", "Admin", new { id = @module.ContentModuleId })"><i class="fa fa-copy"></i> Clone</a></li>
                                    
                                    <li class="hide divider"></li>
                                    
                                  </ul>
                                </div>


                                
                                
                                
                                
                                

                                <a class="button small mobileTop" href="@Url.Action("EditModule", "Admin", new { id = @module.ContentModuleId })" >Code Edit <span class="hide-for-small">{ }</span></a>
                            </td>
                        </tr>
					    }
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>

@section Modals {
    <div id="DeleteModal" class="reveal-modal">
        <h2>Confirm Delete.</h2>
        <p class="lead">Are you sure you want to delete this module?</p>

        <p class=""><span id="popTitle"></span>will be <em>permanently</em> deleted.</p>

        <a id="ConfirmModuleDelete" class="right button confirmDeleteButton confirmModalButton">Confirm</a>
        <a class="right button secondary" onclick="$('#DeleteModal').trigger('reveal:close');">Cancel</a>

        <a class="close-reveal-modal">&#215;</a>
    </div>
}

@section Scripts {
    @{
        // Only load if there is a good reason to
        if (Model.Modules.Count > 0)
        {
            <script src="/Areas/Admin/Scripts/jquery/plugins/jquery.dataTables.min.js"></script>

            <script>
                    $(document).ready(function () {
                        $("table.manageTable").dataTable({
                            "iDisplayLength": 25,
                            "aoColumnDefs": [
                                { "bSortable": false, "aTargets": ["actions"] } // No Sorting on actions
                            ],
                            "aaSorting": [[0, "asc"]] // Sort by module name on load
                        });
                    });
            </script>
        }
    }
}